<?php
namespace Home\Controller;


class LxrController extends HomeController {
    
    public function index(){
        //查董事长名字
        $list = M('user')->where(array('uposition'=>'2'))->select();
        $bossname = $list[0]['name'];
        //查董事电话
        $id1 = $list[0]['id'];
        $list1 = M('userdetail')->where(array('uid'=>$id1))->select();
        $bossphone = $list1[0]['phone'];

        //查经理的
        $jingli = M('userdetail')->where('uid in'.M('user')->field('id')->where(array('uposition'=>'3'))->buildSql())->select();
        
        //查部门
        $arr = M('group')->select();
        $group = [];
        
        foreach ($arr as $k => $v) {
            $group[$v['id']] = $v['groupname'];
        }

        //dump($group);exit;
        $this->assign('name1',$name1['name']);
        $this->assign(bossname,$bossname);
        $this->assign(bossphone,$bossphone);
        $this->assign(jingli,$jingli);
        $this->assign(group,$group);
        $this->display();
    }

    public function doAjax()
    {
        if (!IS_AJAX) {
            $this->error('你是不是迷路了.....');
            exit;
        }
        //接受ajax传值
        $val = I('post.mobile');
        $data = M('userdetail')->where('uid in'.M('user')->field('id')->where(array('groupid'=>$val))->buildSql())->select();
       
        //dump($data);exit;
        // echo json_encode($data);
        $this->ajaxReturn($data);
    }
}